import Vue from 'vue'
import VueRouter from 'vue-router'

// 全局注册 router-view / router-link
Vue.use(VueRouter)

// 准备路由表
const routes = [
  // 默认 重定向到 layout路由
  {
    name: 'default',
    path: '/',
    redirect: '/layout/home'
  },
  // layout 一级路由
  {
    name: 'layout',
    path: '/layout',
    component: () => import('@/views/Layout/index.vue'),
    // 二级路由
    children: [
      {
        path: 'home',
        meta: {
          title: '首页'
        },
        component: () => import('@/views/Home/index.vue')
      },
      {
        path: 'search',
        meta: {
          title: '搜索'
        },
        component: () => import('@/views/Search/index.vue')
      }
    ]
  },
  // play 一级路由
  {
    name: 'play',
    path: '/play',
    component: () => import('@/views/Play/index.vue')
  }
]

// 创建路由管理器对象
const router = new VueRouter({
  routes // 传入 路由表
})

// 导出 路由管理器
export default router
